<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:useBean id="user" class="model.User" scope="session"></jsp:useBean>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Air Transport - Passenger Details</title>
</head>
<body>

<c:if test="${not user.accessed}">
	<c:redirect url="index.html"></c:redirect>
</c:if>

<c:if test="${not user.loggedIn}">
	<c:redirect url="index.html"></c:redirect>
</c:if>

<c:if test="${empty passenger}">
	<c:redirect url="main.html"></c:redirect>
</c:if>




<h2><u>Air Transport Service - Passenger Details</u></h2>

<jsp:include page="header.jsp"></jsp:include>

<c:choose>
	<c:when test="${not empty flights}">

		Flights: <br>
		<table border="1">
			<tr bgcolor="lightgrey">
				<th>No</th>
				<th>Flight ID</th>
				<th>Deparutre Time</th>
				<th>Arrival Time</th>
				<th>Source</th>
				<th>Destination</th>
				<th>Cancellation</th>
			</tr>

			<c:forEach var="flight" items="${flights}" varStatus="status">
				<c:choose>
					<c:when test="${status.index%2 eq 0}">
						<tr bgcolor="#99CCFF">
					</c:when>
					<c:otherwise>
						<tr bgcolor="#CCCCCC">
					</c:otherwise>
				</c:choose>
				<td align="center">${status.index+1}.</td>
				<td align="center"><a href='flight.html?flightid=${flight.id }'>${flight.id
				}</a></td>
				<td align="center">${flight.departureTimeFormated}</td>
				<td align="center">${flight.arrivalTimeFormated}</td>
				<td align="center">${flight.source}</td>
				<td align="center">${flight.destination}</td>

				<c:choose>
					<c:when test="${not flight.expired}">
						<form method="get" action="cancellation.html">
							<td align="center">
								<input type="hidden" name="jmbg" value="${passenger.jmbg}" /> 
								<input type="hidden" name="flightid" value="${flight.id }" /> 
								<input type="submit" value="Cancel" />
							</td>
						</form>
					</c:when>
					<c:otherwise>
						<td>Cancel Exp.</td>
					</c:otherwise>
				</c:choose>

			</c:forEach>

			</tr>

		</table>
	</c:when>
	<c:otherwise>
		Ne postoji nijedan let!<br />
	</c:otherwise>
</c:choose>



<hr />
<p><a href="main.html">Main Page - Flight List</a></p>


<jsp:include page="footer.jsp"></jsp:include>

</body>
</html>